package com.mos.simple.excel;

import com.alibaba.excel.EasyExcel;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.net.URL;

/**
 * Description: <br/>
 * date: 2024/10/28 14:20<br/>
 *
 * @author 小尘哥<br />
 */
public class EasyExcelDemo {

    private static final Logger log = LoggerFactory.getLogger(EasyExcelDemo.class);

    public static void main(String[] args) {
        ClassLoader classLoader = EasyExcelDemo.class.getClassLoader();
        URL resourceUrl = classLoader.getResource("demo/student.xlsx");
        File file = new File(resourceUrl.getFile());
        long start = System.currentTimeMillis();
        EasyExcel.read(file.getAbsoluteFile(), StudentInfo.class,
                        new StudentReaderListener(file.getName()))
                .sheet().doRead();
        long end = System.currentTimeMillis();
        log.info("文件大小：{}Mb，读取耗时{}ms",file.length()/1024/1024, end - start);
    }
}
